package com.leo.boot.web.vo;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

/**
 * 业务状态码
 */
@Getter
@AllArgsConstructor
public enum ResultStatus implements Status {

    /**
     * @see HttpStatus#OK
     */
    OK(200, "操作成功"),
    /**
     * @see HttpStatus#BAD_REQUEST
     */
    BAD_REQUEST(400, "参数错误"),
    /**
     * @see HttpStatus#INTERNAL_SERVER_ERROR
     */
    INTERNAL_SERVER_ERROR(500, "系统错误");

    /**
     * 状态码
     */
    final Integer code;
    /**
     * 状态信息
     */
    final String message;

    public Status format(Object... args) {
        return StatusImpl.of(code, String.format(message, args));
    }

    public Status replace(String message) {
        return StatusImpl.of(code, message);
    }
}
